<?php
require('db.php');

//$vak = $_GET['vak'];
//$user = $_GET['user'];

$result = mysql_query("
SELECT v.id,v.naam,v.omschrijving
FROM vak v
JOIN(
	SELECT vakID
        FROM vakkenperklas
        WHERE klasID=(
        	SELECT klas
                FROM leerling
                WHERE id=1
        )
)x
ON(v.id=x.vakID)
") or die (mysql_error());

$data = array();

while ($row = mysql_fetch_object($result)) {
    $data [] = $row;
}

echo json_encode($data);
?>